//面包屑
// new Vue().$mount('#crumbs');
var sm = new Vue({
    el: "#messageconsultstatistic",
    data: function () {
        return {
            num: '',
            status: '',
            keyword: '',
            msgId: 'a3f50858-dc0f-4fbf-bf75-001bb7eb727c',
            tableData: [],
            total: 0,
            pageSize: 10,
            pageIndex: 1,
            visible: true
        }
    },
    computed:{
        curFilter: function() {
            if(this.curFilterVal === "1") {
                return "全部(" + this.stateCounts[1] + ")";
            } else if(this.curFilterVal === "0") {
                return "未查阅(" + this.stateCounts[0] + ")";
            } else {
                return "已查阅(" + this.stateCounts[2] + ")";
            }
        },
        filtersStatusCount: function() {
            return [{
                text: "全部 (" + this.stateCounts[2] + ")",
                value: ""
            }, {
                text: "已查阅 (" + this.stateCounts[1] + ")",
                value: "1"
            }, {
                text: "未查阅 (" + this.stateCounts[0] + ")",
                value: "0"
            }]
        }
    },
    methods: {
        search: function () {
        },
        getNum: function () {
            VanyAjax("/sendedmsg/getCountByMsgIdAndStatus", {
                msgId: this.msgId
            }, "POST").done(function (data) {
                this.totalnum = data;
            }, false, this);

            VanyAjax("/sendedmsg/getCountByMsgIdAndStatus", {
                msgId: this.msgId,
                receiptStatus: '1'
            }, "POST").done(function (data) {
                this.readed = data;
            }, false, this);
        },
        getData: function (pageIndex, pageSize, msgId, status) {
            VanyAjax("/sendedmsg/getReceiptMsg", {
                pageIndex: pageIndex,
                pageSize: pageSize,
                msgId: msgId,
                receiptStatus: status
            }, "POST").done(function (data) {
                var msgs = data.list;
                this.tableData = msgs;
                this.total = msgs.length;
                for (var i = 0; i < msgs.length; i++) {
                    this.tableData[i].createTime = new Date((msgs[i].createTime)).Format("yyyy-MM-dd hh:mm:ss")
                    if (msgs[i].receiptStatus === "1") {
                        this.tableData[i].consultTime = new Date((msgs[i].receiptTime)).Format("yyyy-MM-dd hh:mm:ss")
                    } else {
                        this.tableData[i].consultTime = "--";
                    }
                }
            }, false, this);
        },
        handleCommand: function (command) {
            this.getData(1, this.pageSize, this.msgId, command);
        },

        handleCurrentChange: function (val) {
            console.log('当前页:' + val);
        },

        handleSizeChange: function (val) {
        }
    },
    mounted: function () {
        this.getData(this.pageIndex, this.pageSize, this.msgId, this.status);
        this.getNum();
    },
})
Date.prototype.Format = function (fmt) {
    var o = {
        "M+": this.getMonth() + 1,                 //月份
        "d+": this.getDate(),                    //日
        "h+": this.getHours(),                   //小时
        "m+": this.getMinutes(),                 //分
        "s+": this.getSeconds(),                 //秒
        "q+": Math.floor((this.getMonth() + 3) / 3), //季度
        "S": this.getMilliseconds()             //毫秒
    };
    if (/(y+)/.test(fmt))
        fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o)
        if (new RegExp("(" + k + ")").test(fmt))
            fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
};